
//
//  YYYCell.m
//  新项目
//
//  Created by 刘耀宗 on 2017/4/3.
//  Copyright © 2017年 刘耀宗. All rights reserved.
//

#import "YYYCell.h"
@interface YYYCell ()
@property (nonatomic, strong) NSMutableArray *mutableArr;
@property (nonatomic, strong) UIView *lineView;
@end
@implementation YYYCell
-(UIView *)lineView
{
    if (_lineView == nil) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor=CcColor(234, 234, 234);
    }
    return _lineView;

}
+(instancetype)CellWithTable:(UITableView *)tableView
{
    NSString *ID=@"YYYCell";
    YYYCell *cell=[tableView dequeueReusableCellWithIdentifier: ID];
    if (cell==nil) {
        cell=[[YYYCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
        
    }
    return cell;
    
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self prepareUI];
        
    }
    return self;
    
}
-(void)prepareUI
{for (int i = 0; i < 11; ++i) {
    
    UILabel *label=[[UILabel alloc] init];
    [self.contentView addSubview:label];
    label.backgroundColor=[UIColor grayColor];
    label.textColor=[UIColor redColor];
    label.layer.cornerRadius=10;
    label.layer.masksToBounds=YES;
    label.font=newFont(12);
    label.textAlignment=NSTextAlignmentCenter;
    [self.mutableArr addObject:label];
    
    
}
    [self.contentView addSubview:self.lineView];
    
    

    
    
}
-(NSMutableArray *)mutableArr
{
    if (_mutableArr == nil) {
        _mutableArr = [NSMutableArray array];
    }
    return _mutableArr;

}

-(void)setArr:(NSArray *)arr
{
    _arr=arr;
    [self.mutableArr enumerateObjectsUsingBlock:^(UILabel *  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        obj.text=arr[idx];
        [obj sizeToFit];
        if (idx==0) {
            obj.backgroundColor=[UIColor yellowColor];
            obj.textColor=[UIColor blueColor];
        }else
        {
        obj.backgroundColor=[UIColor grayColor];
        obj.textColor=[UIColor whiteColor];
        }
    
        
    }];

}
-(void)setNum:(NSInteger)num
{
    _num=num;
    [self.mutableArr enumerateObjectsUsingBlock:^(UILabel *  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if (idx==0) {
            obj.backgroundColor=[UIColor yellowColor];
            obj.textColor=[UIColor blueColor];
        }else
        {
            obj.backgroundColor=[UIColor grayColor];
            obj.textColor=[UIColor whiteColor];
        }
        
    }];
    UILabel *label=self.mutableArr[num];
    label.textColor=[UIColor whiteColor];
    label.backgroundColor=[UIColor redColor];

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    [self.mutableArr enumerateObjectsUsingBlock:^(UILabel *  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        obj.frame=CGRectMake(15+(10+15)*idx, 22-10, 20, 20);
        
    }];
    self.lineView.frame=CGRectMake(0, 44, newwidth, 1);

}

@end
